<template>
    <div class="warehouse-detail">
        <el-dialog
        title="编辑仓库"
        :visible.sync="dialogVisible"
        width="25%">
            <el-form label-width="75px"
              :model="formDat">
                <el-form-item label="仓库名称" >
                    <el-input v-model="formDat.name"></el-input>
                </el-form-item>
                <el-form-item label="仓库地址"  >
                    <el-input v-model="formDat.addr"></el-input>
                </el-form-item>
                <el-form-item label="仓库电话"  >
                    <el-input v-model="formDat.tel"></el-input>
                </el-form-item>
                <el-form-item label="是否启用"  >
                    <el-switch v-model="formDat.status"></el-switch>
                </el-form-item>
                
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import Setting from '../../api/setting';

export default {
    
    data() {
        return {
            formDat: {
                name: '',
                addr: '',
                tel: '',
				id: '',
				status: false
            },
            dialogVisible: false,
            
        };
    },
    
    created() {
    //    this.warehouseList();
    },
    methods: {
        warehouseList() {
            Setting.warehouseList(
                this.status,
                this.current_page, 
                this.num_per_page
            ).then(res=>{
                this.tableDat = res.data.warehouses;
                this.total = res.data.pageDat.total;
            });
        },
        submitForm() {
            // console.log(this.formDat.id);
            if (this.formDat.id) {
                Setting.warehouseSave(this.formDat).then(()=> {
                    this.$emit('update');
                    this.hide();
                });
            } else {
                Setting.warehouseCreate(this.formDat).then(()=> {
                    this.$emit('update');
                    this.hide();
                });
            }
			
        },
        show(item) {
            if (item) {
                this.formDat = item;
            } else {
                this.formDat = {};
            }
            this.dialogVisible = true;
		},
		hide() {
			this.dialogVisible = false;
		}
       
    },



};
</script>
<style>
	.el-row {
		margin-bottom: 20px;
	}
	.el-col {
		border-radius: 4px;
	}
	.bg-purple-dark {
		background: #99a9bf;
	}
	.bg-purple {
		background: #d3dce6;
	}
	.bg-purple-light {
		background: #e5e9f2;
	}
	.grid-content {
		border-radius: 4px;
		min-height: 36px;
	}
	.row-bg {
		padding: 10px 0;
		background-color: #f9fafc;
	}
</style>
